//
//  TMTeacherCommentCell.m
//  国学商家管理
//
//  Created by Tao Li on 2018/7/5.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMTeacherCommentCell.h"
#import "TMCommentModel.h"
@implementation TMTeacherCommentCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    for (UIImageView *ims in self.commentImages) {
        ims.contentMode = UIViewContentModeScaleAspectFill;
        ims.clipsToBounds = YES;
        ims.hidden = YES;
    }
    self.buttomConst.constant = 10;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setModel:(TMCommentModel *)model{
    //1 都有  2 有图片 有消息。3 
    _model = model;
    if (_model.pic.count == 0) {
        for (UIImageView *ims in self.commentImages) {
            ims.hidden = YES;
        }
        self.buttomConst.constant = 10;
    }else{
        self.buttomConst.constant = 95.5;
        NSInteger count = (_model.pic.count >3) ? 3 :_model.pic.count;
        for (NSInteger i = 0; i < count; i ++) {
            UIImageView *im = self.commentImages[i];
            im.hidden = NO;
            [im sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithBaseUrl:_model.pic[i]]] placeholderImage:kPlaceholder];
        }
    }
    self.teacherLabel.text = self.model.username;
    self.dateLabel.text = [SPToolSet stringFromDateString:self.model.create_time];
    self.commentLabel.text = self.model.content;
    for (NSInteger i = 0; i < self.model.star; i ++) {
        if (i >= 5) {
            return;
        }
        UIButton *btn = self.starsBtns[i];
        btn.selected = YES;
    }
}
@end
